﻿Public Structure Album
	Public name As String
	Public artist As String
	Public id As String
	Public url As String
	Public image() As String
	Public tags() As Tag
	Public tracks() As Track
	Public streamable As String
	Public mbid As String
	Public releaseDate As String
	Public listeners As String
	Public playcount As String

	Public Sub New(ByRef xmlAlbum As XElement)
		parseXML(xmlAlbum)
	End Sub

	Public Sub parseXML(ByRef xmlAlbum As XElement)
		Dim count As Integer

		If (xmlAlbum.<name>.Count > 0) Then
			name = xmlAlbum.<name>.Value
		End If
		If (xmlAlbum.<artist>.Count > 0) Then
			artist = xmlAlbum.<artist>.Value
		End If
		If (xmlAlbum.<id>.Count > 0) Then
			id = xmlAlbum.<id>.Value
		End If
		If (xmlAlbum.<mbid>.Count > 0) Then
			mbid = xmlAlbum.<mbid>.Value
		End If
		If (xmlAlbum.<url>.Count > 0) Then
			url = xmlAlbum.<url>.Value
		End If
		If (xmlAlbum.<releaseDate>.Count > 0) Then
			releaseDate = xmlAlbum.<releaseDate>.Value
		End If
		If (xmlAlbum.<listeners>.Count > 0) Then
			listeners = xmlAlbum.<listeners>.Value
		End If
		If (xmlAlbum.<playcount>.Count > 0) Then
			playcount = xmlAlbum.<playcount>.Value
		End If

		count = xmlAlbum.<image>.Count()
		If (count > 0) Then
			ReDim image(0 To count - 1)
			For i As Integer = 0 To count - 1
				image(i) = xmlAlbum.<image>(i).Value
			Next
		End If

		If xmlAlbum.<toptags>.Count() > 0 Then
			count = xmlAlbum.<toptags>.<tag>.Count()
			If (count > 0) Then
				ReDim tags(count - 1)
				For i As Integer = 0 To count - 1
					tags(i) = New Tag(xmlAlbum.<toptags>.<tag>.ElementAt(i))
				Next
			End If
		End If

		If xmlAlbum.<tracks>.Count() > 0 Then
			count = xmlAlbum.<tracks>.<track>.Count()
			If (count > 0) Then
				ReDim tracks(count - 1)
				For i As Integer = 0 To count - 1
					tracks(i) = New Track(xmlAlbum.<tracks>.<track>(i))
				Next
			End If
		End If
	End Sub

End Structure
